/**
 * Author: tianluhua tianlh@qdcares.cn
 * Date: 2025-07-12 10:49:55
 * Description: 
 */
package com.knxhd.config;

import java.time.Duration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.knxhd.listeners.CustomModelListener;

import cn.hutool.core.collection.ListUtil;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;

/**
 * Author: tianluhua tianlh@qdcares.cn
 * Date: 2025-07-12 10:49:55
 * Description: 大模型配置
 */
@Configuration
public class LlmConfig {

  @Autowired
  private CustomModelListener customModelListener;

  @Bean(value = "qwen")
  public ChatModel chatModel() {
    return OpenAiChatModel.builder()
        .apiKey("sk-f237045ef79647c5bd73b24a8619dd01")
        .modelName("qwen-plus-2025-01-25")
        .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
        .temperature(0.8)
        .topP(0.5)
        .maxTokens(8192)
        .listeners(ListUtil.of(customModelListener))
        .maxRetries(3)
        .timeout(Duration.ofSeconds(30))
        .build();
  }

  @Bean(value = "ds")
  public ChatModel dsChatModel() {
    return OpenAiChatModel.builder()
        .apiKey("sk-6ce72a0ee10844dca1ab3d36503bc074")
        .modelName("deepseek-chat")
        .baseUrl("https://api.deepseek.com")
        .temperature(0.8)
        .topP(0.5)
        .maxTokens(8192)
        .listeners(ListUtil.of(customModelListener))
        .build();
  }

}
